<template>
  <div class="dashboard-editor-container">
    <!-- <div class="clearfix">
      <pan-thumb :image="avatar" style="float: left">
        Your roles:
        <span v-for="item in roles" :key="item" class="pan-info-roles">{{
          item
        }}</span>
      </pan-thumb>
      <github-corner
        style="position: absolute; top: 0px; border: 0; right: 0"
      />
      <div class="info-container">
        <span class="display_name">{{ name }}</span>
      </div>
    </div> -->

    <el-row :gutter="20">
      <el-col :md="18">
        <el-card shadow="never" class="mb-20">
          <div class="clearfix user-con">
            <pan-thumb :image="avatar" class="avatar hidden-md-and-down">
              Your roles:
              <span v-for="item in roles" :key="item" class="pan-info-roles">{{
                item
              }}</span>
            </pan-thumb>
            <div class="user-info-con">
              <h2>早安！{{ name }}，祝您开心每一天！</h2>
              <p>
                叮当电商-某某事业部-某某平台部-某某技术部
                <span style="padding-left: 20px"></span>
                上次登录时间： 2020-12-12
              </p>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :md="6">
        <el-card shadow="never" :body-style="{ padding: 0 }" class="mb-20">
          <div slot="header" class="clearfix">
            <span style="display: block; float: left; padding-top: 12px"
              >公告信息</span
            >
            <el-button class="float-right" type="text"
              >更多
              <i class="el-icon-d-arrow-right"> </i>
            </el-button>
          </div>
          <ul class="news-list" style="list-style: none">
            <li><a href="#">机械密封（电力大连开发区热电厂）</a></li>
            <li><a href="#">办公桌（万安水力发电厂）</a></li>
            <li><a href="#">办公桌（万安水力发电厂）</a></li>
            <li><a href="#">办公桌（万安水力发电厂）</a></li>
          </ul>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :md="6">
        <el-card shadow="never" :body-style="{ padding: 0 }" class="mb-20">
          <div class="card first">
            <div class="icon-con"><i class="el-icon-s-help"></i></div>
            <div class="text-con">
              <p>今日投标数</p>
              <span>2568+</span>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :md="6">
        <el-card shadow="never" :body-style="{ padding: 0 }" class="mb-20">
          <div class="card second">
            <div class="icon-con"><i class="el-icon-s-order"></i></div>
            <div class="text-con">
              <p>今日订单数</p>
              <span>3289+</span>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :md="6">
        <el-card shadow="never" :body-style="{ padding: 0 }" class="mb-20">
          <div class="card third">
            <div class="icon-con"><i class="el-icon-s-finance"></i></div>
            <div class="text-con">
              <p>今日收款数</p>
              <span>6528+</span>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :md="6">
        <el-card
          shadow="never"
          style="overflow: visible"
          :body-style="{ padding: 0 }"
          class="mb-20"
        >
          <div class="card forth">
            <div class="vip-icon">
              <span>VIP</span>
              <img src="@/assets/vip.png" alt="" />
            </div>
            <div class="service">
              <p>增值服务</p>
              <div class="btn-group">
                <button type="button">VIP权益</button>
                <button type="button">收费标准</button>
              </div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :md="6" v-for="(card, index) in cards" :key="index">
        <el-card shadow="never" class="mb-20">
          <div slot="header">
            <span>{{ card.title }}</span>
          </div>
          <div class="card-container">
            <div
              v-for="(item, index) in card.content"
              :key="index"
              class="card-item"
            >
              <div>
                <!-- <img :src="'../../../assets/dashboard' + item.icon" alt="" /> -->
                <img :src="require('@/assets/dashboard/' + item.icon)" alt="" />
              </div>
              <span>{{ item.text }}</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :md="24">
        <el-card shadow="never">
          <line-chart :chart-data="lineChartData" />
        </el-card>
      </el-col>

      <!-- <el-col :md="24">
        <el-card shadow="never" :body-style="{ padding: 0 }">
          <pie-chart />
        </el-card>
      </el-col> -->
    </el-row>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import PanThumb from "@/components/PanThumb";
import GithubCorner from "@/components/GithubCorner";
import LineChart from "./components/LineChart";
import PieChart from "./components/PieChart";

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145],
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130],
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130],
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130],
  },
};
export default {
  name: "DashboardEditor",
  components: { PanThumb, GithubCorner, LineChart, PieChart },
  data() {
    return {
      emptyGif:
        "https://wpimg.wallstcn.com/0e03b7da-db9e-4819-ba10-9016ddfdaed3",
      lineChartData: lineChartData.newVisitis,
      cards: [
        {
          title: "寻源待办",
          content: [
            { icon: "1.png", text: "可报名" },
            { icon: "2.png", text: "待报价" },
            { icon: "3.png", text: "待开标" },
            { icon: "4.png", text: "已成交" },
          ],
        },
        {
          title: "履约行为办",
          content: [
            { icon: "5.png", text: "待发货6个" },
            { icon: "6.png", text: "待验收12个" },
            { icon: "7.png", text: "售后待处理8个" },
            { icon: "8.png", text: "订单待审批9个" },
          ],
        },
        {
          title: "结算待办",
          content: [
            { icon: "9.png", text: "待开票99+个" },
            { icon: "10.png", text: "待退票8个" },
            { icon: "11.png", text: "待申请3个" },
            { icon: "12.png", text: "待付款5个" },
          ],
        },
        {
          title: "信息管理",
          content: [
            { icon: "13.png", text: "基本信息管理" },
            { icon: "14.png", text: "资质证书管理" },
            { icon: "15.png", text: "经营范围管理" },
            { icon: "16.png", text: "运费管理" },
          ],
        },
      ],
    };
  },
  computed: {
    ...mapGetters(["name", "avatar", "roles"]),
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type];
    },
  },
};
</script>

<style lang="scss" scoped>
.emptyGif {
  display: block;
  width: 45%;
  margin: 0 auto;
}

.dashboard-editor-container {
  background-color: #e3e3e3;
  min-height: 100vh;
  padding: 30px 30px 0px;
  .pan-info-roles {
    font-size: 12px;
    font-weight: 700;
    color: #333;
    display: block;
  }
  .info-container {
    position: relative;
    margin-left: 190px;
    height: 150px;
    line-height: 200px;
    .display_name {
      font-size: 48px;
      line-height: 48px;
      color: #212121;
      position: absolute;
      top: 25px;
    }
  }
}
.user-con {
  display: flex;
  flex-direction: row;

  .avatar {
    width: 120px;
  }
  .user-info-con {
    display: flex;
    padding-left: 20px;
    flex-direction: column;
    justify-content: center;

    h1,
    p {
      margin: 0;
    }
  }
}
.news-list {
  li {
    line-height: 22px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
.card {
  display: flex;
  flex-direction: row;
  height: 110px;
  position: relative;
  .vip-icon {
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 35px;
    img {
      max-width: 100%;
    }
    span {
      position: absolute;
      left: 50%;
      top: 4px;
      transform: translateX(-50%);
      color: #ed4020;
      font-size: 16px;
    }
  }

  &.first {
    background: #2da1f9;
  }
  &.second {
    background: #67ca29;
  }
  &.third {
    background: #fca006;
  }
  &.forth {
    background: linear-gradient(140deg, #f5967b 10%, #f05427 100%);
  }

  .icon-con {
    width: 110px;
    height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 70px;
    color: #fff;
  }
  .text-con {
    display: flex;
    flex-direction: column;
    justify-content: center;
    p,
    span {
      padding: 0;
      margin: 0;
      color: #fff;
    }
    p {
      font-size: 20px;
      margin-bottom: 5px;
    }
    span {
      font-size: 36px;
      letter-spacing: 2px;
    }
  }

  .service {
    padding: 0 30px;
    width: 80%;
    margin: 0 auto;
    p {
      color: #fff;
    }
    .btn-group {
      display: flex;
      justify-content: space-between;
      button {
        background: transparent;
        border: 1px solid #fff;
        padding: 5px 20px;
        color: #fff;
        outline: none;
        cursor: pointer;

        & + button {
          margin-left: 10px;
        }
      }
    }
  }
}
.card-container {
  width: 100%;
  display: flex;
  flex-wrap: wrap;

  .card-item {
    width: 50%;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    i {
      font-size: 40px;
      margin-bottom: 10px;
      color: #1ea0ff;
    }
    span {
      font-size: 16px;
      color: #666;
    }
  }
}
</style>
